#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "../BaseObj.h"
#include "../Configuration/Configuration.h"
#include "../RequestParser/RequestParser.h"
#include "../../app/controllers/controller.h"
#include <time.h>

class BaseApp: public BaseObj{
	public:
		void start();
	private:
 };


 
void BaseApp::start()
{
	clock_t start,end;
	start = clock ();


	//string *pNew=new string[1];
	//*pNew="test";
	try{
		Configuration::initialize();
		//cout<<Configuration::myMapConfig["key"]<<endl;
		//cout<<"Content-type: text/html\n\n"<<"<html><title>Hello</title><body>\n";
		RequestParser::initialize();
		//call controller
		new Controller();
	}
	catch(string str){
			cerr<<str<<endl;
			cerr<<"in "+RequestParser::view<<endl;
			exit(1);
		}
	catch(char const* str){
		cerr<<str<<endl;
		cerr<<"in "+RequestParser::view<<endl;
		exit(1);
	}
	catch(exception& e){
		cout << "# ERR: in " << __FILE__;
		  cout << "(" << __FUNCTION__ << ") on line "  << __LINE__ << endl;
		  cout << "# ERR: " << e.what();


		cerr << "Something went wrong..."<<endl<<e.what()<<endl<<"in "+RequestParser::view<<endl;
		exit(1);
	}

   end= clock ();

   cout<<endl<<"Time load: "<< end-start<<" ms";
	//cout<<"</body></html>";
	
	
	
}




